package com.niodata.dp.core.exception;

public interface ErrorCodes {

  //输入参数异常
  int ERROR_PARAM = 400;
  //用户不存在
  int ERROR_USER_NOT_EXISTS = 100;
  //组不存在
  int ERROR_GROUP_NOT_EXISTS = 200;
  //密码错误
  int ERROR_PASSWORD_ERROR = 101;
  //权限不足
  int ERROR_PERMISSION_DENIED = 403;
  //HDFS异常
  int ERROR_HDFS = 300;
  //流程管理模块异常
  int ERROR_TASK = 600;
  //系统异常
  int ERROR_INTERNAL = 500;
  //KDC认证服务器异常
  int ERROR_KDC = 800;
  //LDAP服务异常
  int ERROR_LDAP = 900;
  //JDBC链接异常
  int ERROR_JDBC = 1001;
  //MongoDB链接异常
  int ERROR_MONGO = 1002;
  //HIVE仓库链接异常
  int ERROR_HIVE = 1003;
  //查询失败
  int ERROR_QUERY = 1100;
  //配置失败
  int ERROR_CONFIG = 1200;
  //系统异常
  int SYSTEM_EXCEPTION = 1300;
  int PLUGIN_UPDATE_ERROR = 1400;

  /**
   * get error msg.
   */
  static String getErrorMsg(int code) {
    switch (code) {
      case ERROR_PARAM:
        return "输入参数异常";
      case ERROR_USER_NOT_EXISTS:
        return "用户不存在";
      case ERROR_GROUP_NOT_EXISTS:
        return "组不存在";
      case ERROR_PASSWORD_ERROR:
        return "密码错误";
      case ERROR_PERMISSION_DENIED:
        return "权限不足";
      case ERROR_HDFS:
        return "HDFS异常";
      case ERROR_TASK:
        return "流程管理模块异常";
      case ERROR_INTERNAL:
        return "系统内部异常";
      case ERROR_KDC:
        return "KDC认证服务器异常";
      case ERROR_LDAP:
        return "LDAP服务异常";
      case ERROR_JDBC:
        return "JDBC链接异常";
      case ERROR_MONGO:
        return "MongoDB链接异常";
      case ERROR_HIVE:
        return "HIVE仓库链接异常";
      case ERROR_QUERY:
        return "查询失败";
      case ERROR_CONFIG:
        return "配置失败";
      case SYSTEM_EXCEPTION:
        return "系统异常";
      case PLUGIN_UPDATE_ERROR:
        return "插件更新失败，meta.json不匹配";
      default:
        return "系统异常";
    }
  }
}
